<%@page import="java.util.ArrayList"%>
<%@page import="sopt.engSearch.NaverSearchProc"%>
<%@page import="statics.SoptVars"%>
<%@page import="sopt.engSearch.TranslateProc"%>
<%@page import="comm.util.RequestManager"%>
<%@page import="comm.util.SoptHashMap"%>
<%@page import="sopt.engSearch.ESKoreaProc"%> 
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	SoptHashMap hm = RequestManager.getRequest(request);
	ESKoreaProc proc = new ESKoreaProc();
	String curStr =  hm.get("Q").toString();
	
	String translateStr = TranslateProc.getTranslatedString(curStr,SoptVars.ENG_TO_KOR);
	ArrayList lt = proc.getSuggestList(curStr);
	
%>
<%if(lt!=null&&lt.size()>0){ %>
<div id="suggestResultBg">
	<div>
		<span style="float:left;"><img src="../images/ico_eng.png" width="30" height="30"/><%=curStr%></span>
		<span style="float:right;"><%=translateStr %><img src="../images/ico_kor.png" width="30" height="30"/></span>
	</div>
	<div class="clear"></div>		
	<div id="suggestResultContent">
	<%for(int i=0;i<lt.size();i++){
			SoptHashMap sgMap = (SoptHashMap)lt.get(i);%>
		<div class="suggestResultItem" id="<%=sgMap.get("TRANSLATED_NAME")%>">
			<%
			String translatedStr = sgMap.get("TRANSLATED_NAME").toString();
			String lower_keyword = translatedStr.toLowerCase().replaceFirst(curStr.toLowerCase(),"<b>"+curStr.toLowerCase()+"</b>");
			%>
			<span style="float:left;"><%=lower_keyword%></span>
			<span style="padding:0 15px;"> </span>
			<span style="float:right;"><%=sgMap.get("NAME")%></span>
			<div class="clear"></div>
		</div>
	<%}%>
	</div>
	<div id="koreaSparkling">powered by <a href="http://visitkorea.or.kr"><img src="../images/korea_sparkling_logo.gif" title="Korea Sparkling"/></a></div>
</div>
<%}else{
	
	lt = NaverSearchProc.getSuggestQueryList( translateStr ,7);
	
	if(lt!=null && lt.size()>0){
%>
	<div id="suggestResultBg">
		<div>
			<span style="float:left;"><img src="../images/ico_eng.png" width="30" height="30"/><%=curStr%></span>
			<span style="float:right;"><%=translateStr %><img src="../images/ico_kor.png" width="30" height="30"/></span>
		</div>
		<div class="clear"></div>		
		<div id="suggestResultContent">
		<%for(int i=0;i<lt.size();i++){
			String curOriginStr = lt.get(i).toString();
			String curTrans = TranslateProc.getTranslatedString(curOriginStr,SoptVars.KOR_TO_ENG);%>
			<div class="suggestResultItem" id="<%=curOriginStr%>">
				<span style="float:left;"><%=curTrans%></span>
				<span style="padding:0 15px;"> </span>
				<span style="float:right;"><%=curOriginStr%></span>
				<div class="clear"></div>
			</div>
		<%}%>
		</div>
		<div id="koreaSparkling">related keywords powered by <a href="http://naver.com"><img src="../images/lg_naver_v3.gif" title="Naver"/></a></div>
	</div>
	<%}else{ %>
	<div id="suggestResultBg">
		<div>
			<span style="float:left;"><img src="../images/ico_eng.png" width="30" height="30"/><%=curStr%></span>
			<span style="float:right;"><%=translateStr %><img src="../images/ico_kor.png" width="30" height="30"/></span>
		</div>
		<div class="clear"></div>
		<div style="text-align: right;font-style:italic;">
			<p>Sorry, Cannot find any matched suggest KEYWORD result.</p>
			<p>If you type correctly, just Search it!</p>
		</div>
	</div>
	<%} %>
<%}%>
